package com.lab;

import com.lab.http.LabHttpConfig;
import com.lab.push.BBSPushProtocol;
import com.lab.push.MainPushProtocol;
import com.lab.user.UserLifecycle;

public final class LabConfig {
    private Builder builder;
    private LabConfig(Builder builder){
        this.builder = builder;
    }

    Builder getBuilder() {
        return builder;
    }

    UserLifecycle userLifecycle(){
        return builder.userLifecycle;
    }

    BBSPushProtocol bbsPushProtocol(){
        return builder.bbsPushProtocol;
    }

    MainPushProtocol mainPushProtocol(){
        return builder.mainPushProtocol;
    }

    LabHttpConfig labHttpConfig(){return builder.labHttpConfig;}

    public static class Builder{
        private UserLifecycle userLifecycle;
        public Builder userLifecycle(Class<? extends UserLifecycle> userLifecycle){
            try {
                this.userLifecycle = userLifecycle.newInstance();
            } catch (Exception ignored) {
                this.userLifecycle = null;
            }
            return this;
        }

        private BBSPushProtocol bbsPushProtocol;
        public Builder bbsPushProtocol(Class<? extends BBSPushProtocol> bbsPushProtocol){
            try {
                this.bbsPushProtocol = bbsPushProtocol.newInstance();
            } catch (Exception ignored) {
                this.bbsPushProtocol = null;
            }
            return this;
        }

        private MainPushProtocol mainPushProtocol;
        public Builder mainPushProtocol(Class<? extends MainPushProtocol> mainPushProtocol){
            try {
                this.mainPushProtocol = mainPushProtocol.newInstance();
            } catch (Exception ignored) {
                this.mainPushProtocol = null;
            }
            return this;
        }

        private LabHttpConfig labHttpConfig;
        public Builder labHttpConfig(LabHttpConfig labHttpConfig){
            this.labHttpConfig =  labHttpConfig;
            return this;
        }

        public LabConfig build(){
            return new LabConfig(this);
        }


    }


}
